// pages/wodetuandui/wodetuandui.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    getTeamUrl: app.data.url +'/mapi/newfenxiao/getteam',
    title:[
      {
        name:'一级',
        number:2,
      },
      {
        name: '二级',
        number: 0,
      }, 
      {
        name: '三级',
        number: 0,
      },
    ],
    indexs:0,
    shuju:[
      [],
      [],
      []
    ]
  },



  aa: function (e) {
    console.log(e.currentTarget.dataset.index);
    var index = e.currentTarget.dataset.index;
    this.setData({indexs:index});
  },
  ab: function () {
    wx.navigateTo({
      url: '/pages/wodetuanduiyi/wodetuanduiyi',
    })
  },
  ac: function () {
    wx.navigateTo({
      url: '/pages/wodetuanduier/wodetuanduier',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var user = wx.getStorageSync('user');
    wx.showLoading({
      title: '加载中',
    })
    wx.request({
      url: that.data.getTeamUrl,
      data:{token:user.token},
      method:'post',
      success:function(res){
        var data = res.data;
        if(data.code==200){
          var shuju = [];
          var title = that.data.title;
          shuju.push(data.data.yiji);
          title[0].number = data.data.yiji.length;
          shuju.push(data.data.erji);
          title[1].number = data.data.erji.length;
          shuju.push(data.data.sanji);
          title[2].number = data.data.sanji.length;
          that.setData({shuju:shuju,title:title})
          console.log(shuju);
        }else{
          wx.showToast({
            title: data.msg,
            icon:'none'
          })
        }
        wx.hideLoading();
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
      this.onLoad();
    wx.stopPullDownRefresh({
      success: function () {
        console.log('返回了')
      }
    });
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    var user = wx.getStorageSync('user');
    var titles = wx.getStorageSync('titles');
    return {
      title: titles,
      path: '/pages/index/index?scene' + user.id,
    };
  }
})